<?php  declare(strict_types=1);
namespace App\Controllers;


use Framework\{
	App,
	Controller
};

use Monolog\{
	Logger,
	Handler\StreamHandler,
	Handler\FirePHPHandler
};


use Framework\Database\Db;
use App\Models\User;

use GuzzleHttp\Client;

use Resource\Request;
use Framework\Redis\Connection;

// use Framework\Facades\Request;
// use Framework\Facades\Config;

// use Config;

class IndexController extends Controller
{

	function index($request, $name='99')
	{
		// print_r( App::$aliases );

		// $queue = \App\Jobs\DownloadJob::dispatch([
		// 	'url' => 'xxxxxx'
		// ]);
		// var_dump($queue->url);

		// $redis = new Connection();

		// echo $redis->version();


		// echo $redis->executeCommand('set', ['name', 'tangzhangming']);
		// echo $redis->executeCommand('get', ['name']);

		// echo $redis->get('name');

		// Redis::get('name');

		$session = $request->session();


		// $session->set('name', 'fff');
		// echo $session->get('user_id');


		// $session->forget('name');
		// print_r( $session->all() );


		return 'end';
	}

	public function queue()
	{
		//将作业推送到队列并获得其ID
		$id = \App\Jobs\DownloadJob::dispatch();


	}

	public function test()
	{
		//组件调用方式1 
		app()->response;
		app()->request;
		app()->config;

		//组件调用方式2
		app('response')->json(['name'=>'999']);
		app('request')->url();
		app('config')->get('app.name');
	}



	public function error()
	{
		echo '错误页面...';
		return '错误页面...:(';
	}

	public function request($value='')
	{
		$request->cookie('user_id');
		app()->response->cookie('usersss_id', 999);
	}

	public function FunctionName($value='')
	{
		$blade = new \Blade\Blade([
			
            'compression' 	=> false,
            'debug' 		=> true,

		]);



		return $blade->renderFile('welcome', [
			'title' => 'this title',
			'name' => '<script>sss</script>',

			'status' => $status,

			'number' => 100,

			'jsondata' => [
				'a' => '999',
				'b' => '888',
				'b' => '777',
				'b' => '666',
				'b' => '555',
			]
		]);

	}
}